import { sys } from 'cc';

interface IUserInfo {
    headUrl: string
    id: number
    nickname: string | null
    maxScore: number
    rank: number
    rankName: string | null
    ranking: number
    totalScore: number
}

const userInfo: IUserInfo = {
    headUrl: 'https://file.bendiclass.com/oss/image/xiehouyu.png',
    id: 1,
    nickname: null,
    maxScore: 2,
    rank: 0,
    rankName: "",
    ranking: 0,
    totalScore: 0
}


export default class userStore {
    public static userInfo = userInfo
    public static appId = 'wxcc3adba6426ef960'
    public static token: String | void = sys.localStorage.getItem('token') || 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ7XCJpZFwiOjIsXCJvcGVuaWRcIjpcIm9qM2dfNVFpb3R6LUhBOE1hUWJ4VFJBRnM5Tm9cIixcInR5cGVcIjpcImxpdHRsZV9nYW1lX3VzZXJcIn0iLCJqdGkiOiIyIiwiaWF0IjoxNjc1MTMyNzE1LCJleHAiOjE2Nzc3MjQ3MTV9.BM-WkSHycx90SX-CSCZx-K4mukW7RdcSKyKp-CTUTn2JNmuwqZqczpW0xUecQPQHUWw-OdK91kDd411_NabYaw'

    

    public static setUserInfo(value) {
        userStore.userInfo = { ...userStore.userInfo, ...value }
        // console.log(userStore.userInfo, 'userStore.userInfo')
    }

    public static setToken(value) {
        userStore.token = value
        sys.localStorage.setItem('token', value)
    }
}
